package com.etc.service.impl;

import com.etc.dao.AreaMapper;
import com.etc.entity.Area;
import com.etc.service.AreaService;
import com.etc.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 林铭淞
 * 省市service实现
 */
@Service
public class AreaServiceImpl implements AreaService {

	@Autowired
	private AreaMapper areaMapper;

	/**
	 * 省市分页加模糊查询，暂时用不到
	 * @param page
	 * @param pageSize
	 * @param content
	 * @return
	 */
	@Override
	public PageData<Area> selectAreaByPage(int page, int pageSize, String content) {
		int start = (page - 1) * pageSize;
		int count = areaMapper.selectCount(content);
		List<Area> list = areaMapper.selectAreaByPage(start, pageSize, content);
		PageData<Area> pd = new PageData<>(list, count, pageSize, page, content);
		return pd;
	}

	/**
	 * 查询所有省份
	 * @return
	 */
	@Override
	public List<Area> selectProvince() {
		return areaMapper.selectProvince();
	}

	/**
	 * 通过省份id查询该省所有城市
	 * @param provinceId
	 * @return
	 */
	@Override
	public List<Area> selectCity(Integer provinceId) {
		return areaMapper.selectCity(provinceId);
	}
}
